package com.huntero.picscale;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;

public class PreviewViewPager extends ViewPager implements OnChildMovingListener{
    public static final String TAG = "PreviewViewPager";
    boolean isChildMoving = false;
    public PreviewViewPager(@NonNull Context context) {
        super(context);
    }

    public PreviewViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        Log.i(TAG, "onInterceptTouchEvent: " + (isChildMoving));
        if(isChildMoving)return false;
        return super.onInterceptTouchEvent(ev);
    }

    @Override
    public void onStartMoving() {
        isChildMoving = true;
    }

    @Override
    public void onStopMoving() {
        isChildMoving = false;
    }
}
